<style lang="scss" scoped>
.container {
  padding: 0 16px;
}

.el-select .el-select--small {
  display: block !important;
}
</style>
<style lang="scss">
  .alignLeft > .cell{
    text-align: left !important;
  }
</style>

<!-- 页面布局-->
<template>
  <div class="table">
    <!-- 主体区 -->
    <div class="container">
      <div class="grid-data-box" style="width: 850px;">
        <el-table v-loading="tableLoading" :data="tableData" max-height="350" border style="width: 100%" ref="singleTable" highlight-current-row :cell-style="{padding:'3px 0 !important'}">
            <el-table-column type="index" width="50" label="序号"></el-table-column>
            <el-table-column prop="logDesc" show-overflow-tooltip label="描述" class-name="alignLeft"></el-table-column>
            <el-table-column prop="statusName" width="200" show-overflow-tooltip label="申请批次状态" align="center"></el-table-column>
            <el-table-column prop="timestamp" width="200" show-overflow-tooltip label="操作时间"></el-table-column>
        </el-table>
        <div class="navigate-box">
          <div class="pagination">
            <el-pagination background @current-change="handleCurrentChange" :total="parampters.totalCount" @size-change="handleSizeChange" :current-page.sync="parampters.pageIndex" :page-sizes="[20, 50, 100, 200]" :page-size="parampters.pageRows" layout="total, sizes, prev, pager, next"></el-pagination>
          </div>
        </div>
      </div>
     
      <!-- 表单区END -->
      <!-- 按钮操作区 -->
      <span slot="footer" class="form-btn-box" style="margin-top: 10px;">
        <el-button @click="cnacelForm()">取 消</el-button>
      </span>
      <!-- 按钮操作区END -->

    </div>
    <!-- 主体区END -->

    
  </div>
</template>
<script>
import applybatchUpdForm from "./applybatch_upd_form"
export default {
  data() {
    return {
      // 筛选条件
      parampters: {
        //查询参数
        pageRows: 20, //每页行数
        pageIndex: 1, //当前页
        pageCount: 0, //总页数
        totalCount: 0, //总记录数
        province: null,
        city: null,
        provinceCode: "",
        cityCode: "",
        productName: "",
        dnsegNum: "",
        starttime: "",
        endtime: ""
      },
      // 提交表单的loading设置标识
      fullscreenLoading: false,
      firstLoadedData: "{}",
      // 表单校验规则
      //所选记录id
      selectedId: "",
      //事物类型
      actType: "",
      // 表单只读状态
      readOnly: false,
      //字典集
      dicts: {},
      tableLoading: true,
      tableData: [],
      cardNumTol: 0,
      spNo: "",
      canSelDnseg: false, //未选择省市时，不可以选择号段
    };
  },
  props: {
    sourceData: {
      required: true
    }
  },
  // 进入页面加载数据
  mounted() {
    this.handleInitLoad();
  },
  methods: {
    /**
     * 组件初始化加载
     */
    handleInitLoad() {
      this.initSelectOptoins();
      this.searchLoad();
    },

    /**
     * 初始加载字典选项
     */
    initSelectOptoins() {
      this.loadSelectOptoins("province", {"isp":10010});
      this.loadSelectOptoins("sp", {"isp":10010});
      this.loadSelectOptoins("cardFace", {"isp":10010});
    },

    /**
     * 通用定义:下拉字典
     *  @augments dictKind 字典类型
     */
    loadSelectOptoins(dictKind, params) {
      let url = "/rps/" + dictKind + "/";
      this.$axios
      .get(url, {
        params: params,
        headers:{
            operator: this.$util.getLoginer().userid,
            withCredentials: true
        }
      })
      .then(res => {
        let data = res.data;
        if (data.success) {
          this.$set(this.dicts, dictKind, data.data.list);
        } else {
          this.$error( "查询失败" + data.message );
        }
      })
      .catch(err => {
        console.log(err);
      });
    },

    /**
     * 取消返回
     * @augments formName 表单名称
     */
    cnacelForm(formName) {
      this.$emit("ok", null);
    },

    /**
     * @augments val 页码
     * 切换页码操作
     */
    handleCurrentChange(val) {
      this.parampters.pageIndex = val;
      // 重新获取当前页码的数据
      this.searchLoad();
    },

    /**
     * @augments val 每页显示条数
     * 每页显示条数修改
     */
    handleSizeChange(val) {
      // 修改每页显示条数
      this.parampters.pageRows = val;
      // 重新获取数据
      this.searchLoad();
    },
    
    /**
     *初始化加载表单数据
     */
    searchLoad() {
      this.selectedId = this.sourceData.seleid;
      var url = `/rps/cardApplyBatch/${this.selectedId}/log/?` + new Date().getTime();
      this.tableLoading = true;
      this.$axios
        .get(url, {
            params: this.parampters,
            headers: {
              operator: this.$util.getLoginer().userid,
              withCredentials: true
            }
          }
        )
        .then(res => {
          let data = res.data;
          if (data.success) {
            this.tableData = data.data.list;
            this.tableLoading = false;
            this.parampters.pageIndex =
              data.data.pageNum != undefined ? parseInt(data.data.pageNum) : 0;
            this.parampters.pageCount =
              data.data.totalPage != undefined ? parseInt(data.data.totalPage) : 0;
            this.parampters.totalCount =
              data.data.count != undefined ? parseInt(data.data.count) : 0;
            if(this.tableData != null && this.tableData != undefined && this.tableData.length > 0){
              this.spNo = this.tableData[0].spNo;
            }
          } else {
            this.tableLoading = false;
            this.$error(data.message);
          }
        })
        .catch(err => {
          this.tableLoading = false;
          console.log(err);
        });
    },

    toUpd(row){
    },

    formatter(row, column) {
      if (column.property == "provinceCode") {
				return row.provinceName;
      }
      if (column.property == "cityCode") {
				return row.cityName;
      }
      if (column.property == "spNo") {
				return row.spName;
      }
    },

  }
};
</script>
